package wechat.rcv.controller

import org.apache.log4j.Logger
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RequestMethod
import com.shrcl.engineerprocess.domain.Notification
import org.springframework.beans.factory.annotation.Autowired
import edu.fudan.mylang.pf.IObjectFactory
import org.springframework.web.bind.annotation.RestController

@RestController
class ChangeNotifiedStatus {
	
	final static Logger logger = Logger.getLogger(typeof(ChangeNotifiedStatus).getName());
	@Autowired IObjectFactory entities;
	@RequestMapping(value="/changestatus", method = RequestMethod.GET)
	
	def StatusResponse process(Long notificationId) {
		logger.info('=========>ChangeNotifiedStatus.processs<============')
		
		val result = new StatusResponse()
		try{
			val n = entities.get(typeof(Notification), notificationId);
			n.confirm("微信确认")
			logger.info('=========>ChangeNotifiedStatus.isConfirmed<============'+n.isConfirmed)
			result.success = n.isConfirmed
		} catch(Exception e){
			result.success = false
			e.printStackTrace
		}
		return result
	}
}


class StatusResponse {
	
	public Boolean success
	
}